home *** CD-ROM | disk | FTP | other *** search
- local i l j n f IFS k
- onerr goto err
- onintr goto err
- n=#argv,IFS="\n"
- j=1-(n<2),f=0,k=10
- while j<n
- if left(argv[j], 1) == '-' && numeric(argv[j])
- if argv[j] < 0
- k = -argv[j]
- endif
- j++
- continue
- endif
- if j>0
- if (f=open(argv[j],"r")) == 0
- j++
- continue
- endif
- read l <&$f
- if eof(f)
- goto empty
- endif
- echo "==> $argv[$j] <=="
- echo $l
- i=1
- else
- f=i=0
- endif
- while i++<k;read l <&$f;if eof(f);break;endif;echo $l;endwhile
- label empty
- close $f
- f=0,j++
- endwhile
- label err
- if f
- close $f
- endif
- # head - print the first few lines of a file/files. The innermost while
- # is compressed to one line for performance.
- #
- # Head is presented as is; no warrantee is either expressed or implied
- # as to it's suitability to any purpose whatsoever. You assume all the
- # risk for all damage, even if caused by a defect in the software,
- # no matter how awful.
-